function QuizDetailView(params){
	
	var win = Ti.UI.createWindow({
		title: params.title,
		currQuestNum: params.currQuestNum,
		prevQuestNum: params.prevQuestNum,
		optionSelected: params.optionSelected,
		numCorrAnswers: params.numCorrAnswers,
		backgroundColor: "#FFF"
	});
	
	var file = Ti.Filesystem.getFile('xml/quiz.xml');
	var contents = file.read();
	var xmltext = Ti.XML.parseString(contents.text);
	
	if ( file.exists() ){
		var quizChapters = [];
		var quizHomeView = Titanium.UI.createTableView({
			top: 0,
			height: Ti.UI.FILL,
			backgroundColor: "transparent",
	    	data: quizChapters
		});
		
		var quiz = xmltext.documentElement.getElementsByTagName('chapter');

		for (var i=0; i<quiz.length; i++){
			
			var chapter = quiz.item(i).getElementsByTagName('chapternumber').item(0).textContent;
			if(params.title == chapter){
				
				var questions = quiz.item(i).getElementsByTagName('question');			
				for (var x=0; x<questions.length; x++){
			
					var questionNumber = questions.item(x).getElementsByTagName('questionnumber').item(0).textContent;
					if (params.currQuestNum == questionNumber){
						var showResults = "no";
						
						var questionText = questions.item(x).getElementsByTagName('questiontext').item(0).textContent;
						var optionElems = questions.item(x).getElementsByTagName('option');
						
						var options = [];
						for (var y=0; y<optionElems.length; y++){
							var singleOption = optionElems.item(y).textContent;
							options.push(singleOption);
						}
						
						var answer = questions.item(x).getElementsByTagName('answer').item(0).textContent;
						break;
					}
				}
				break;
			}
		}	
	    
	    if(showResults == "no"){		
	
			var headerLabel = Ti.UI.createLabel({
				text: 'Question ' + questionNumber,
				font: {
					fontSize: "16dp",
					fontFamily: (Ti.Platform.osname === "android") ? "Aller_Bd" : "Aller",
					fontWeight: "bold" //Android will ignore this
				},
				top: "20dp",
				textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
				color: "#000"
			});
			
			var questionLabel = Ti.UI.createLabel({
				text: questionText,
				font: {
					fontSize: "12dp",
					fontFamily: (Ti.Platform.osname === "android") ? "Aller_Bd" : "Aller",
					fontWeight: "bold" //Android will ignore this
				},
				top: "50dp",
				textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,
				color: "#000"
			});
				
			var optionsButton = Titanium.UI.createButtonBar({
				labels: options,
				backgroundColor:'#336699',
			    bottom:"150dp",
			    style:Titanium.UI.iPhone.SystemButtonStyle.BAR,
			    height:25,
			    width:200,
			    answer: answer,
			});
		
			win.add(headerLabel);
			win.add(questionLabel);
			win.add(optionsButton);
		}
		else { //show results
	
			var resultsLabel = Ti.UI.createLabel({
				text: 'Results Page!',
				font: {
					fontSize: "16dp",
					fontFamily: (Ti.Platform.osname === "android") ? "Aller_Bd" : "Aller",
					fontWeight: "bold" //Android will ignore this
				},
				top: "20dp",
				textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
				color: "#000"
			});
			
			win.add(resultsLabel);
		}	
	}
	return win;
}
module.exports = QuizDetailView;